﻿using FreeSql;
using System;
using System.Linq.Expressions;

namespace TK.FreeSqlExtension.Repository
{
    /// <summary>
    /// MyDefaultRepository
    /// </summary>
    internal class MyDefaultRepository<TEntity, TKey> : BaseRepository<TEntity, TKey> where TEntity : class
    {
        /// <summary>
        /// ctor
        /// </summary>
        public MyDefaultRepository(IFreeSqlFactory fsqlFactory)
            : base(fsqlFactory.GetFreeSql(), null, null)
        {
        }

        /// <summary>
        /// ctor
        /// </summary>
        public MyDefaultRepository(IFreeSqlFactory fsqlFactory, Expression<Func<TEntity, bool>> filter)
            : base(fsqlFactory.GetFreeSql(), filter, null)
        {
        }

        /// <summary>
        /// ctor
        /// </summary>
        public MyDefaultRepository(IFreeSqlFactory fsqlFactory, UnitOfWorkManager uowManger)
            : base(uowManger?.Orm ?? fsqlFactory.GetFreeSql(), null, null)
        {
            uowManger?.Binding(this);
        }
    }
}
